package xyz.zyl2020.java8.function;

import java.util.function.Predicate;

/**
 * @author ZhuYinglong
 * @date 2020/10/11 0011
 */
public class PredicateDemo {

    public static void main(String[] args) {
        predicateDemo1();
        predicateDemo2(1024, integer -> integer == 1024);
    }

    /**
     * new一个Predicate实例
     */
    static void predicateDemo1() {
        Predicate<Integer> predicate = integer -> integer == 1024;
        System.out.println("predicateDemo1 --> " + predicate.test(1024));
    }

    /**
     * Predicate做为参数传递
     *
     * @param integer
     * @param predicate
     */
    static void predicateDemo2(Integer integer, Predicate<Integer> predicate) {
        System.out.println("predicateDemo1 --> " + predicate.test(integer));
    }
}
